<?php
/*
 *                        _oo0oo_
 *                       o8888888o
 *                       88" . "88
 *                       (| -_- |)
 *                       0\  =  /0
 *                     ___/`---'\___
 *                   .' \\|     |// '.
 *                  / \\|||  :  |||// \
 *                 / _||||| -:- |||||- \
 *                |   | \\\  - /// |   |
 *                | \_|  ''\---/''  |_/ |
 *                \  .-\__  '-'  ___/-. /
 *              ___'. .'  /--.--\  `. .'___
 *           ."" '<  `.___\_<|>_/___.' >' "".
 *          | | :  `- \`.;`\ _ /`;.`/ - ` : | |
 *          \  \ `_.   \_ __\ /__ _/   .-` /  /
 *      =====`-.____`.___ \_____/___.-`___.-'=====
 *                        `=---='
 * 
 * 
 *      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 * 
 *            佛祖保佑       永不宕机     永无BUG
 */
/*
 * 首页
 * @Author: htong
 * @Date: 2021-03-02 18:16:55
 * @LastEditors: htong
 * @LastEditTime: 2021-03-02 18:39:06
 * @Description: file content
 * @FilePath: \gongchengqiaojob\Application\Home\Controller\PcIndexapiController.class.php
 */
namespace Home\Controller;
use Common\Controller\PcApiController;
use Common\ORG\PublicFunction;
use Common\ORG\WxFunction;
use Think\Db;

class PcIndexapiController extends PcApiController{
	
	public function _initialize() {

        $getsecret  = $_SERVER['HTTP_APPSECRET'];
        //取head标签内容
        if(!preg_match('/^\w{8}-\w{4}-\w{4}-\w{4}-\w{12}$/', $getsecret) && ACTION_NAME<>'getUserInfo'){
            $this->ajaxReturn(1, 'appsecret格式错误');
        }

        if($this->appsecret <> $getsecret && ACTION_NAME<>'getUserInfo'){
            $this->ajaxReturn(1, 'appsecret错误');
        }
        parent::_initialize();
    }

	/**
    * @name: 首页
    * @description: 
    * @Author: htong
    * @msg: 
    * @param {*}
    * @return {*}
    */
	public function index(){
        $user =  $this->userinfo;
        if($user['utype'] !=1) {
            $this->ajaxReturn(1, L('auth_null'));//用户不存在
        }
        
        $MembersSettaocan = M('MembersSettaocan')->where(array('uid'=>$user['uid']))->find();
        $join = 'join ' . C('DB_PREFIX') . 'jobs j on j.id=' . C('DB_PREFIX') . 'personal_jobs_apply.jobs_id';
        $total_nolook_resume_today = M('PersonalJobsApply')->join($join)->where(array('company_uid' => $user['uid'],'is_reply' => array('eq', 0),'apply_addtime'=> array('between',array(strtotime(date('Y-m-d 00:00:00')),strtotime(date('Y-m-d 23:59:59'))))))->count();
        $total_nolook_resume = M('PersonalJobsApply')->join($join)->where(array('company_uid' => $user['uid'], 'is_reply' => array('eq', 0)))->count();
        $total_nolook_resume_no = M('PersonalJobsApply')->join($join)->where(array('company_uid' => $user['uid'], 'is_reply' => array('eq', 0),'personal_look'=>1))->count();
        $amount_of_downloads = M('CompanyDownResume')->where(array('company_uid' => $user['uid'], 'is_del' => array('eq', 0)))->count();
        $total_interview = M('CompanyInterview')->where(array('company_uid' => $user['uid']))->count();
        $consultants_looking_for_talents = M('Order')->where(array('fa_type' =>2,'refund_status'=>0,'uid'=>$user['uid']))->count();
        $eward_for_talent = M('Order')->where(array('fa_type' =>3,'refund_status'=>0,'uid'=>$user['uid']))->count();
        $consultants_recommend_talents = M('Order')->where(array('fa_type' =>4,'refund_status'=>0,'uid'=>$user['uid']))->count();
        $posts_in_publishing = M('Jobs')->where(array('audit' =>1,'uid'=>$user['uid']))->count();
        $data = $this->get_left_useritem();
        $data['total_nolook_resume_today'] = $total_nolook_resume_today;//今日投递的简历数
        $data['total_nolook_resume'] = $total_nolook_resume;//投递的简历总数
        $data['total_nolook_resume_no'] = $total_nolook_resume_no;//未读简历数
        $data['amount_of_downloads'] = $amount_of_downloads;//下载次数
        $data['total_interview'] = $total_interview;//面试人数
        $data['consultants_looking_for_talents'] = $consultants_looking_for_talents;//通过顾问找人才
        $data['eward_for_talent'] = $eward_for_talent;//悬赏找人才
        $data['consultants_recommend_talents'] = $consultants_recommend_talents;//顾问推举人才
        $settaocan = [];
        $settaocan['jl_down_num'] =  $MembersSettaocan['jl_down_num'];
        $settaocan['jl_down_surplus'] =  $MembersSettaocan['jl_down_num']- $MembersSettaocan['jl_yi_down_num'];
        $settaocan['duan_qi_fa_count'] =  $MembersSettaocan['duan_qi_fa_count'];
        $settaocan['duan_qi_fa_surplus'] =  $MembersSettaocan['duan_qi_fa_count']- $MembersSettaocan['duan_qi_yi_fa_count'];;
        $settaocan['xmzc_fa_count'] =  $MembersSettaocan['xmzc_fa_count'];
        $settaocan['xmzc_fa_surplus'] =  $MembersSettaocan['xmzc_fa_count']- $MembersSettaocan['xmzc_yi_fa_count'];;
        $settaocan['ji_zhao_fa_count'] =  $MembersSettaocan['ji_zhao_fa_count'];
        $settaocan['ji_zhao_fa_surplus'] =  $MembersSettaocan['ji_zhao_fa_count']- $MembersSettaocan['ji_zhao_yi_fa_count'];;
        $settaocan['cg_fa_count'] =  $MembersSettaocan['cg_fa_count'];
        $settaocan['cg_yi_fa_surplus'] =  $MembersSettaocan['cg_fa_count']- $MembersSettaocan['cg_yi_fa_count'];;
        $settaocan['end_time']=date('Y-m-d H:i:s',$MembersSettaocan['end_time']);
        $data['has_taocan']=0;
        if($MembersSettaocan){
           $data['has_taocan']=1;
        }
        $data['members_settaocan'] = $settaocan;//套餐数据
        $data['posts_in_publishing'] = $posts_in_publishing;//发布中的职位
        $this->ajaxReturn(0, 'ok', $data);
        
	}
	

}
?>